package com.yuhanginfo.modules.sys.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yuhanginfo.common.persistence.Page;
import com.yuhanginfo.common.service.TreeService;
import com.yuhanginfo.modules.sys.dao.AreaDao;
import com.yuhanginfo.modules.sys.entity.Area;
import com.yuhanginfo.modules.sys.utils.UserUtils;

/**
 * 区域Service
 * @author YuHangInfo
 * @version 2014-05-16
 */
@Service
@Transactional(readOnly = true)
public class AreaService extends TreeService<AreaDao, Area> {
    @Autowired
    private AreaDao areaDao;
	public List<Area> findAll(){
		return UserUtils.getAreaList();
	}

	@Transactional(readOnly = false)
	public void save(Area area) {
		super.save(area);
		UserUtils.removeCache(UserUtils.CACHE_AREA_LIST);
	}
	
	@Transactional(readOnly = false)
	public void delete(Area area) {
		super.delete(area);
		UserUtils.removeCache(UserUtils.CACHE_AREA_LIST);
	}

	public List<Area> areaStoreList() {
		
		return areaDao.areaStoreList();
	}
	
	//门店区域列表
	public Page<Area> storeAreaList(Page<Area> page, Area area) {
		area.setPage(page);
		page.setList(areaDao.storeAreaList(area));
		return page;
	}
    
	@Transactional(readOnly = false)
	public void areaInsert(Area area) {
		areaDao.areaInsert(area);
		
	}

	public List<Area> useStoreList() {
		
		return areaDao.useStoreList();
	}

	public List<Area> selectProvinceList() {
		
		return areaDao.selectProvinceList();
	}

	public List<Area> selectCityList(String id) {
		
		return areaDao.selectCityList(id);
	}

	public List<Area> selectcnName(String cnName) {
		
		return areaDao.selectcnName(cnName);
	}

	public List<Area> getProvince() {
		
		return areaDao.getProvince();
	}

	public List<Area> selectByParent(String id) {
		
		return areaDao.selectByParent(id);
	}
}
